
package petrivis.view;

import java.awt.event.MouseEvent;
import prefuse.controls.DragControl;
import prefuse.visual.DecoratorItem;
import prefuse.visual.VisualItem;

/**
 * A Control that allows drag elements but if a Decorator is drag, it is the
 * decorated item who is drag
 * @author Jorge Munoz
 */
public class NotDecoratorsDragControl extends DragControl{

    public NotDecoratorsDragControl() {
        super();
    }

    @Override
    public void itemEntered(VisualItem item, MouseEvent e) {
        if(item instanceof DecoratorItem) super.itemEntered(((DecoratorItem)item).getDecoratedItem(), e);
        else super.itemEntered(item, e);
    }

    @Override
    public void itemExited(VisualItem item, MouseEvent e) {
        if(item instanceof DecoratorItem) super.itemExited(((DecoratorItem)item).getDecoratedItem(), e);
        else super.itemExited(item, e);
    }
    
    @Override
    public void itemPressed(VisualItem item, MouseEvent e) {
        if(item instanceof DecoratorItem) super.itemPressed(((DecoratorItem)item).getDecoratedItem(), e);
        else super.itemPressed(item, e);
    }

    @Override
    public void itemReleased(VisualItem item, MouseEvent e) {
        if(item instanceof DecoratorItem) super.itemReleased(((DecoratorItem)item).getDecoratedItem(), e);
        else super.itemReleased(item, e);
    }

    @Override
    public void itemDragged(VisualItem item, MouseEvent e) {
        if(item instanceof DecoratorItem) super.itemDragged(((DecoratorItem)item).getDecoratedItem(), e);
        else super.itemDragged(item, e);
    }

}
